using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class Forums_PrivateMessageMap : EntityTypeConfiguration<Forums_PrivateMessage>
    {
        public Forums_PrivateMessageMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Subject)
                .IsRequired()
                .HasMaxLength(450);

            this.Property(t => t.Text)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("Forums_PrivateMessage");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.StoreId).HasColumnName("StoreId");
            this.Property(t => t.FromCustomerId).HasColumnName("FromCustomerId");
            this.Property(t => t.ToCustomerId).HasColumnName("ToCustomerId");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.Text).HasColumnName("Text");
            this.Property(t => t.IsRead).HasColumnName("IsRead");
            this.Property(t => t.IsDeletedByAuthor).HasColumnName("IsDeletedByAuthor");
            this.Property(t => t.IsDeletedByRecipient).HasColumnName("IsDeletedByRecipient");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.Forums_PrivateMessage)
                .HasForeignKey(d => d.FromCustomerId);
            this.HasRequired(t => t.Customer1)
                .WithMany(t => t.Forums_PrivateMessage1)
                .HasForeignKey(d => d.ToCustomerId);

        }
    }
}
